package com.moleq.models;

import com.moleq.db.DatabaseSchema;

public class RoundingSetting {
//	CREATE TABLE t_rounding_setting
//	(rs_id INTEGER NOT NULL,
//	rs_name varchar(50) NOT NULL,
//	rs_down_value numeric(8,2) NOT NULL,
//	rs_up_value numeric(8,2) NOT NULL,
//	rs_to_value numeric(8,2) NOT NULL,
//	PRIMARY KEY (rs_id));
	private int rs_id;
	private String rs_name;
	private double rs_down_value;
	private double rs_up_value;
	private double rs_to_value;
	private String rs_optional = "0";
	private String type;
	private boolean isEdit = false;
	private int no;
	public int getNo() {
		return no;
	}
	public void setNo(int no) {
		this.no = no;
	}
	public RoundingSetting(){}
	public RoundingSetting(int rs_id,String rs_name,double rs_down_value,double rs_up_value,double rs_to_value,String rs_optional){
		this.rs_id = rs_id;
		this.rs_name = rs_name;
		this.rs_down_value = rs_down_value;
		this.rs_up_value = rs_up_value;
		this.rs_to_value = rs_to_value;
		this.rs_optional = rs_optional;
	}
	
	public int getRs_id() {
		return rs_id;
	}
	public void setRs_id(int rs_id) {
		this.rs_id = rs_id;
	}
	public String getRs_name() {
		return rs_name;
	}
	public void setRs_name(String rs_name) {
		this.rs_name = rs_name;
	}
	public double getRs_down_value() {
		return rs_down_value;
	}
	public void setRs_down_value(double rs_down_value) {
		this.rs_down_value = rs_down_value;
	}
	public double getRs_up_value() {
		return rs_up_value;
	}
	public void setRs_up_value(double rs_up_value) {
		this.rs_up_value = rs_up_value;
	}
	public double getRs_to_value() {
		return rs_to_value;
	}
	public void setRs_to_value(double rs_to_value) {
		this.rs_to_value = rs_to_value;
	}
	
	public String getRs_optional() {
		return rs_optional;
	}
	public void setRs_optional(String rs_optional) {
		this.rs_optional = rs_optional;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public boolean isEdit() {
		return isEdit;
	}
	public void setEdit(boolean isEdit) {
		this.isEdit = isEdit;
	}
	
	public boolean isRs_optional(){
		return this.getRs_optional().equals("1")?true:false;
	}
	
	public String toMGData(String Action) {
		String Result = Action + "|" + DatabaseSchema.RoundingSetting.SCHEMA_NAME
				+ "|(" + getRs_id() + "," + CheckNull(getRs_name()) + "," + getRs_down_value()
				+ "," + getRs_up_value() + "," + getRs_to_value() + "," + CheckNull(getRs_optional()) +")";
		return Result;
	}
	
	public String CheckNull(String value){
		if(value == null){
			return null;
		}else{
			return "'" + value + "'";
		}
	}
	public boolean getOptional() {
		boolean result = this.getRs_optional().toString().equals("1");
		return result;
	}
}
